package com.ch.engine.statemachine.machine;

import com.ch.engine.statemachine.builder.SopProcessBuilder;
import com.ch.engine.statemachine.enums.Event;
import com.ch.engine.statemachine.enums.State;
import com.ch.engine.statemachine.handler.*;
import com.ch.engine.statemachine.pojo.SopProcess;

import java.util.Arrays;
import java.util.List;

/**
 * 新状态机/复杂状态机
 */
public class NewStateMachine extends AbstractStateMachine {

    /**
     * 初始化数据
     *
     * @return 初始化数据
     */
    @Override
    List<SopProcess> init() {
        return Arrays.asList(
                SopProcessBuilder.getInstance()
                        .from(State.UN_SUBMIT)
                        .event(Event.SUBMIT)
                        .to(State.LEADER_CHECK)
                        .handler(new SubmitHandler())
                        .build(),
                SopProcessBuilder.getInstance()
                        .from(State.LEADER_CHECK)
                        .event(Event.PASS)
                        .to(State.HR_CHECK)
                        .handler(new LeaderPassHandler())
                        .build(),
                SopProcessBuilder.getInstance()
                        .from(State.LEADER_CHECK)
                        .event(Event.REJECT)
                        .to(State.REJECT)
                        .handler(new LeaderRejectHandler())
                        .build(),
                SopProcessBuilder.getInstance()
                        .from(State.HR_CHECK)
                        .event(Event.PASS)
                        .to(State.FINISH)
                        .handler(new HrPassHandler())
                        .build(),
                SopProcessBuilder.getInstance()
                        .from(State.HR_CHECK)
                        .event(Event.REJECT)
                        .handler(new HrRejectHandler())
                        .to(State.REJECT)
                        .build()
        );
    }
}
